#pragma once
#include <atlbase.h>
#include <xmllite.h>
#include <gdiplus.h>

#include <string>
#include <memory>

#include "Element.h"

using std::wstring;
using std::string;
using std::unique_ptr;
using Gdiplus::Bitmap;

class CImageElement :
	public CElement
{
public:
	CImageElement(void);
	~CImageElement(void);

	virtual void DoFill(IHTMLDocument2* document) throw(...);
	wstring GetText(IHTMLDocument2* document) const throw(...);

protected:
	//wstring _value;
	//wstring _hierarchy;
	//wstring _method;

	//virtual void InitElementFromXml(IXmlReader* pReader) throw(...);
	virtual void BuildAvailableAttributes() throw();
	virtual void ValidateAttributes() const throw(...);

private:
	void CopyImage(IHTMLDocument2* document, IHTMLElement* e) const throw(...);
	unique_ptr<Bitmap> GetOriginalImage() const throw(...);
	unique_ptr<Bitmap> Decorate(Bitmap* source) const throw(...);
	string OCR(Bitmap* source) const throw(...);
	wstring Revise(const string& code) const throw(...);
};

